package cn.edu.mju.cooprateflat.common;

import com.jfinal.core.Controller;
import com.jfinal.json.FastJson;
import com.jfinal.kit.StrKit;

import java.util.HashMap;
import java.util.Map;

public abstract class ManageBaseController extends Controller {
    protected Map<String,Object> params(){
        Map<String,Object> params = null;
        String data = this.getRawData();
        if(StrKit.notBlank(data)){
            params = FastJson.getJson().parse(data, HashMap.class);
        }else{
            params = new HashMap<>();
        }
        return params;
    }
    protected Object params(String key){
        if(StrKit.isBlank(key)){
            return null;
        }
        Map<String, Object> params = this.params();
        if(params.containsKey(key)){
            return params.get(key);
        }else{
            return null;
        }
    }
}
